package com.zr.task.controller;

import java.util.List;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;

import com.zr.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zr.common.annotation.Log;
import com.zr.common.core.controller.BaseController;
import com.zr.common.core.domain.AjaxResult;
import com.zr.common.enums.BusinessType;
import com.zr.task.domain.EimTaskHospitalLocation;
import com.zr.task.service.IEimTaskHospitalLocationService;
import com.zr.common.utils.poi.ExcelUtil;
import com.zr.common.core.page.TableDataInfo;

/**
 * 医院位置经纬度Controller
 * 
 * @author why
 * @date 2022-10-27
 */
@RestController
@RequestMapping("/eim/location")
public class EimTaskHospitalLocationController extends BaseController
{
    @Autowired
    private IEimTaskHospitalLocationService eimTaskHospitalLocationService;

    /**
     * 查询医院经纬度列表
     * @param eimTaskHospitalLocation 包含医院名称的对象
     * @return
     */
    @GetMapping("/list")
    @PermitAll
    public TableDataInfo list(EimTaskHospitalLocation eimTaskHospitalLocation)
    {
        startPage();
        List<EimTaskHospitalLocation> list = eimTaskHospitalLocationService.selectEimTaskHospitalLocationList(eimTaskHospitalLocation);
        return getDataTable(list);
    }

    /**
     * 导出医院位置经纬度列表
     */
    @PreAuthorize("@ss.hasPermi('eim:location:export')")
    @Log(title = "医院位置经纬度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EimTaskHospitalLocation eimTaskHospitalLocation)
    {
        List<EimTaskHospitalLocation> list = eimTaskHospitalLocationService.selectEimTaskHospitalLocationList(eimTaskHospitalLocation);
        ExcelUtil<EimTaskHospitalLocation> util = new ExcelUtil<EimTaskHospitalLocation>(EimTaskHospitalLocation.class);
        util.exportExcel(response, list, "医院位置经纬度数据");
    }

    /**
     * 获取医院位置经纬度详细信息
     */
    @PreAuthorize("@ss.hasPermi('eim:location:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(eimTaskHospitalLocationService.selectEimTaskHospitalLocationById(id));
    }

    /**
     * 新增医院位置经纬度
     */
    @PreAuthorize("@ss.hasPermi('eim:location:add')")
    @Log(title = "医院位置经纬度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EimTaskHospitalLocation eimTaskHospitalLocation)
    {
        return toAjax(eimTaskHospitalLocationService.insertEimTaskHospitalLocation(eimTaskHospitalLocation));
    }

    /**
     * 修改医院位置经纬度
     */
    @PreAuthorize("@ss.hasPermi('eim:location:edit')")
    @Log(title = "医院位置经纬度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EimTaskHospitalLocation eimTaskHospitalLocation)
    {
        return toAjax(eimTaskHospitalLocationService.updateEimTaskHospitalLocation(eimTaskHospitalLocation));
    }

    /**
     * 删除医院位置经纬度
     */
    @PreAuthorize("@ss.hasPermi('eim:location:remove')")
    @Log(title = "医院位置经纬度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eimTaskHospitalLocationService.deleteEimTaskHospitalLocationByIds(ids));
    }
}
